package homework.work7;

import java.util.Arrays;
import java.util.Random;

public class Main {
    public static void main(String[] args) {
        String[] s=new String[8];
        for (int i = 0; i < s.length; i++) {
            s[i]=generateRandomString(5);
        }
        System.out.println("数组的内容是： "+java.util.Arrays.toString(s));
        Arrays.sort(s);

    }

    private static String generateRandomString(int length){
        String characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder sb=new StringBuilder();
        Random random = new Random();
        for(int i=0;i<length;i++){
            int index=random.nextInt(characters.length());
            sb.append(characters.charAt(index));
        }
        return sb.toString();
    }
}
